package edu.washington.cs.sounddetector.server.api.methodresult;

import java.util.List;

import edu.washington.cs.sounddetector.server.api.MethodResult;
import edu.washington.cs.sounddetector.server.api.method.GetOldNotifications;
import edu.washington.cs.sounddetector.server.api.object.Notification;

public class GetOldNotificationsResult extends MethodResult<GetOldNotifications>
{

    private List<Notification> notifications;
    private String phoneId;

    private GetOldNotificationsResult(boolean successful, FailureReason reason,
            List<Notification> notifications, String phoneId)
    {
        super(successful, reason);
        this.notifications = notifications;
        this.phoneId = phoneId;
    }

    private GetOldNotificationsResult()
    {
        this(true, null, null, null);
    }

    /**
     * @return if {@link #isSuccessful()} == true, returns the list of notifications the phone has
     *         not yet seen. Otherwise, returns null.
     */
    public List<Notification> getNotifications()
    {
        return notifications;
    }

    /**
     * @return if {@link #isSuccessful()} == false, returns the phoneId of the phone that does not
     *         exist on the server. Otherwise, returns null.
     */
    public String getPhoneId()
    {
        return phoneId;
    }

    public static GetOldNotificationsResult success(List<Notification> notifications)
    {
        return new GetOldNotificationsResult(true, null, notifications, null);
    }

    public static GetOldNotificationsResult failurePhoneDoesNotExist(String phoneId)
    {
        return new GetOldNotificationsResult(false, FailureReason.PHONE_DOES_NOT_EXIST, null,
                phoneId);
    }

}
